package com.lxy.demo.dao;

import com.lxy.demo.entity.City;
import com.lxy.demo.utils.DruidManger;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CityDaoImpl implements CityDao {
    QueryRunner qr = new QueryRunner(DruidManger.getDataSource());
    @Override
    public List<City> findCity() {
        String sql = " select * from City ";
        try {
            return qr.query(sql,new BeanListHandler<City>(City.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
